<%@page import="org.springframework.security.core.context.SecurityContextHolder"%>
<%@page import="org.apache.commons.lang.StringUtils"%>
<%@page import="org.apache.commons.lang.time.DateFormatUtils"%>
<%@page import="org.springframework.util.CollectionUtils"%>
<%@page import="java.util.Collection"%>
<%@page import="java.text.SimpleDateFormat"%>
<%@ include file="../common/common_include.jsp"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	UserInfo user = (UserInfo)SecurityContextHolder.getContext().getAuthentication().getPrincipal();
	String username = user.getName();
	TblCheckMend mend = null;
	if (null != request.getAttribute("mend")){
		mend = (TblCheckMend) request.getAttribute("mend");
	}
	String defaultSiteId = request.getAttribute("defaultSiteid")!=null?request.getAttribute("defaultSiteid")+"":"";
	SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM");
	String year_moth = sdf.format(new Date());
	String destroy  = request.getAttribute("destroy")!= null?request.getAttribute("destroy")+"":"";
%>

<div>
	<form target="_coreIframe"  method="post" action="<%=request.getContextPath()%>/check/doEditMend" enctype="multipart/form-data">
		<div class="breadcrumb">
			<div class="bcIcon"></div>
			<ul class="bcNav">
				<li id="toptitle">补卡修改</li>
			</ul>
		</div>
		<table class="formTable">
			<input type="hidden" name="id" value="<%=mend.getId()+""%>">
			<input type="hidden" name="siteid" value="<%=mend.getSiteid()%>">
			<tr>
				<td class="tdTitle">所属公司：</td>
				<td>
					<input class="inputText xs" type="text" name="sitename" value="<%=mend.getSitename() %>" readonly>
					<span class="errorTipWrap" id="errorTip_siteid"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">工号：</td>
				<td>
					<input class="inputText xs" type="text" name="userid" value="<%=mend.getUserid() %>" readonly>
					<span class="errorTipWrap" id="errorTip_userid"></span>
				</td>
			</tr>				
			<tr>
				<td class="tdTitle">员工：</td>
				<td>
					<input class="inputText xs" type="text" name="username" value="<%=mend.getUsername() %>" readonly>
					<span class="errorTipWrap" id="errorTip_username"></span>
				</td>
			</tr>	
			<tr>
				<td class="tdTitle">补卡类型 ：</td>
				<td>
					<select name="type">
						<option value="0" <%=mend.getType() == 0 ?"selected=selected":""%>>上班卡</option>
						<option value="1" <%=mend.getType() == 1 ?"selected=selected":""%>>下班卡</option>
					</select>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">考勤日期：</td>
				<td>
				<input class="inputText xs" type="text" value="<%=DateFormatUtils.format(mend.getCheckdate(), "yyyy-MM-dd")%>" name="checkdate" onClick="WdatePicker({dateFmt:'yyyy-MM-dd'})">
				<span class="errorTipWrap" id="errorTip_checkdate"></span>
				</td>
			</tr>			
			<tr>
				<td class="tdTitle">时段1：</td>
				<td>
					<input id="time1" name="time1" style="width:80px;" value="<%=mend.getTime1() != null ? DateFormatUtils.format(mend.getTime1(), "HH:mm"):""%>">
					<span class="errorTipWrap" id="errorTip_time1"></span>
				</td>
			</tr>
			<tr>
				<td class="tdTitle">时段2：</td>
				<td>
					<input id="time2" name="time2" style="width:80px;" value="<%=mend.getTime2() != null ? DateFormatUtils.format(mend.getTime2(), "HH:mm"):""%>">
				</td>
			</tr>
			<tr>
				<td class="tdTitle">时段3：</td>
				<td>
					<input id="time3" name="time3" style="width:80px;" value="<%=mend.getTime3() != null ? DateFormatUtils.format(mend.getTime3(), "HH:mm"):""%>">
				</td>
			</tr>							
			<tr>
				<td class="tdTitle">补卡原因：</td>
				<td><input class="inputText xs" type="text"  value="<%=mend.getReason()!=null ? mend.getReason():"" %>" name="reason">
				</td>
			</tr>
			<tr>
				<td class="tdTitle"></td>
				<td>
					<div>
						<input class="input-btn-microsoft" type="submit" value="提交">
						<a id="cancel" class="a-btn-microsoft" href="javascript:XF.Check.mendList()">取消</a>
					</div>
				</td>
			</tr>	
		</table>
	</form>
	<iframe id="_coreIframe" name="_coreIframe" style="display: none;"></iframe>
</div>

<script>
	$('#time1').timespinner({
	    showSeconds: false
	});
	$('#time2').timespinner({
	    showSeconds: false
	});
	$('#time3').timespinner({
	    showSeconds: false
	});	
	$(document).ready(function() {
		var d = <%=destroy%>+"";
		if(d == '1'){
			$("#toptitle").html("员工申请补卡销毁");
			$('input[name=reason]').attr('readonly','readonly');
			$('input[name=checkdate]').removeAttr('onclick').attr('readonly',"readonly");
			$('input[name=time1]').attr('readonly',"readonly");
			$('input[name=time2]').attr('readonly',"readonly");
			$('input[name=time3]').attr('readonly',"readonly");
			var userTr = "<tr><td class='tdTitle'><font color='#FF0000'>补卡销毁原因:</font></td>";
			userTr += "<td><input class='inputText xs' type='text'  name='remark'><span><font color='#FF0000'>只填写销毁原因即可</font></span><span class='errorTipWrap' id='errorTip_remark'></span></td></tr>"
			userTr += "<input type='hidden' name='flag' value='3'>";
			$("tr:last").before(userTr);
			var url="<%=request.getContextPath()%>/check/doUserDestroyMend"
			$("form").attr("action",url);
		}else if(d == 3){
			$("#toptitle").html("人事部补卡不通过");
			$('input[name=reason]').attr('readonly','readonly');
			$('input[name=checkdate]').removeAttr('onclick').attr('readonly',"readonly");
			$('input[name=time1]').attr('readonly',"readonly");
			$('input[name=time2]').attr('readonly',"readonly");
			$('input[name=time3]').attr('readonly',"readonly");
			$('#cancel').attr("href","javascript:XF.Check.mendPersonList('<%=year_moth %>','<%=defaultSiteId %>')")
			var userTr = "<tr><td class='tdTitle'><font color='#FF0000'>不通过原因：<font></td>";
			userTr += "<td><input class='inputText xs' type='text'  name='personremark'><span><font color='#FF0000'>只填写不通过原因即可</font></span><span class='errorTipWrap' id='errorTip_personremark'></span></td></tr>"
			userTr += "<input type='hidden' name='personflag' value='1'>";
			userTr += "<input type='hidden' name='personuser' value='<%=username%>'>"
			$("tr:last").before(userTr);
			var url="<%=request.getContextPath()%>/check/doNoPersonMend"
			$("form").attr("action",url);
		}else if(d == 2){
			$("#toptitle").html("部门不通过");
			$('input[name=reason]').attr('readonly','readonly');
			$('input[name=checkdate]').removeAttr('onclick').attr('readonly',"readonly");
			$('input[name=time1]').attr('readonly',"readonly");
			$('input[name=time2]').attr('readonly',"readonly");
			$('input[name=time3]').attr('readonly',"readonly");
			$('#cancel').attr("href","javascript:XF.Check.mendDeptList('<%=year_moth %>','<%=user.getSiteId() %>','<%=user.getDeptId() %>')");
			var userTr = "<tr><td class='tdTitle'><font color='#FF0000'>不通过原因：<font></td>";
			userTr += "<td><input class='inputText xs' type='text'  name='deptremark'><span><font color='#FF0000'>只填写不通过原因即可</font></span><span class='errorTipWrap' id='errorTip_deptremark'></span></td></tr>"
			userTr += "<input type='hidden' name='deptflag' value='1'>";
			userTr += "<input type='hidden' name='deptuser' value='<%=username%>'>"
			$("tr:last").before(userTr);
			var url="<%=request.getContextPath()%>/check/doNoDeptMend"
			$("form").attr("action",url);
		}else if(d = 4){
			$('#cancel').attr("href","javascript:XF.Check.mendPersonList('<%=year_moth %>','<%=defaultSiteId %>')")
			var url="<%=request.getContextPath()%>/check/doEditPersonMend"
			$("form").attr("action",url);
		}
	});
	
</script>

